﻿using System;
using System.ComponentModel.Composition;
using System.Reflection;
using AlanAamy.Net.TemperatureConverter.Infrastructure.Constants;
using AlanAamy.Net.TemperatureConverter.Infrastructure.Frameworks.RX;
using log4net;

namespace AlanAamy.Net.TemperatureConverter.Models
{
    public interface IRightSequenceObserverModel
    {
        IObservable<Decimal> GetObservable();
        TemperatureUnit Unit { get; set; }
        Decimal Value { get; set; }
        void ToggleUnit();
        event EventHandler ValueChanged;
        event EventHandler UnitChanged;
    }

    [Export(typeof(IRightSequenceObserverModel))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class RightSequenceObserverModel : ObservableSequence<Decimal,TemperatureUnit>, IRightSequenceObserverModel
    {
        private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        [ImportingConstructor]
        public RightSequenceObserverModel()
        {
            Log.Info("");
            Value = 33.8M;
            Unit = TemperatureUnit.Farenheit;
        }

        public void ToggleUnit()
        {
            Unit = 1 - Unit;
        }

    }
}
